package LeetCode.exercise;

public class LC153 {
    public static void main(String[] args) {
        LC153 l = new LC153();
        l.findMin(new int[] {3,4,5,1,2});
    }
    public int findMin(int[] nums) {
        int left = 0, right = nums.length - 1;
        if (nums[right] > nums[left]) return 0;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] < nums[nums.length - 1]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return left;
    }
}
